package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.DepotTypeDao;
import com.hy.erp.inventory.dao.interfaces.IDepotTypeDao;
import com.hy.erp.inventory.pojo.DepotType;
import com.hy.erp.inventory.pojo.interfaces.IDepotType;
import com.hy.erp.inventory.service.interfaces.IDepotTypeService;
import com.hy.erp.inventory.service.interfaces.IdepotDao;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:18:10</li>
 * <li>类型名称：DepotTypeService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "depotTypeService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
*/
@Component("depotTypeService")
public class DepotTypeService extends AbstractBusinessService < DepotTypeDao > implements IDepotTypeService{

	private IDepotTypeDao depotTypeDao=null;

	@Resource(name="depotTypeDao")
	public void setPositionTypeDao(IDepotTypeDao depotTypeDao) {
		this.depotTypeDao = depotTypeDao;
	}
	
	@Override
	public boolean addDepotType(DepotType depotType) {




		if ( null == depotType)
		{
			return true ;
		}
		
		else
		{
			/*System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			IDepotTypeDao depotTypeDao =
			                       ( IDepotTypeDao ) this
			                                          .getDao ( IDepotType.class ) ;*/
			
			return depotTypeDao
			                .persist ( depotType ) ;
		}
		
	
	
	
	
	}

	@Override
	public boolean modifyDepotType(DepotType depotType) {




		if ( ( null == depotType )
			     || ( null == depotType
			                                .getIdentifier ( ) )
			     || ( depotType
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

		//		IDepotTypeDao depotTypeDao =
       //             ( IDepotTypeDao ) this
       //                                .getDao ( IDepotType.class ) ;

		
					
				if ( null == depotType )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (depotTypeDao
				                  .merge ( depotType ) != null ) ;
			}
		
	
	
	
	
	}

	@Override
	public Integer removeDepotType(String[] depotTypeIds) {




		if ( ( null == depotTypeIds)
			     || ( depotTypeIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{


//
		//		IDepotTypeDao depotTypeDao =
      //              ( IDepotTypeDao ) this
          //                             .getDao ( IDepotType.class ) ;
		

				return depotTypeDao
				                .remove ( depotTypeIds ) ;
			}
	
	
	
	
	}

	@ Override
	public String [ ] addDepotType (
										Object [ ] depotType )
	{

		if ( null == depotType)
		{
			return null ;
		}
		
		else
		{
		
		//	IDepotTypeDao depotTypeDao =
		//	                       ( IDepotTypeDao ) this
		//	                                          .getDao ( IDepotType.class ) ;

			DepotType[] depotTypes=new DepotType[depotType.length];
						for(int i=0;i<depotType.length;i++)
						{
							DepotType depotType2=( DepotType ) depotType[i];
							depotTypes[i]=depotType2;
						}
						return depotTypeDao
						                .persist ( depotTypes ) ;
			
			
		}
		
	
	
	
	
	
	}

	@ Override
	public List < DepotType > getAllDepotType ( )
	{

	//	IDepotTypeDao depotTypeDao =
    //        ( IDepotTypeDao ) this
    //                           .getDao ( IDepotType.class ) ;
		return depotTypeDao
		                .find ( ) ;
	}

	@ Override
	public String [ ] modifyDepotType (
										Object [ ] depotType )
	{


		if ( null == depotType)
		{
			return null ;
		}
		
		else
		{
		
	//		IDepotTypeDao depotTypeDao =
	//		                       ( IDepotTypeDao ) this
		//	                                          .getDao ( IDepotType.class ) ;

			DepotType[] depotTypes=new DepotType[depotType.length];
						for(int i=0;i<depotType.length;i++)
						{
							DepotType depotType2=( DepotType ) depotType[i];
							depotTypes[i]=depotType2;
						}
						return depotTypeDao
						                .merge ( depotTypes ) ;
			
			
		}
		
	
	
	
	
	
	
	}

}
